void miotMode(uint8_t mode)
{
    BLINKER_LOG("need set mode: ", mode);

    if (mode == BLINKER_CMD_MIOT_DAY)
    { // 院子灯打开
        count_time_ya = millis();
        if (count_time_ya - count_time_ya_cash >= 3000)
        {
            count_time_ya_cash = millis();
            httpClientRequest(3);
        }
    }
    else if (mode == BLINKER_CMD_MIOT_NIGHT)
    { // 里间灯打开
        count_time_living = millis();
        if (count_time_living - count_time_living_cash >= 3000)
        {
            count_time_living_cash = millis();

            httpClientRequest(2);
        }
    }
    else if (mode == BLINKER_CMD_MIOT_COLOR)
    { // 院子灯关闭
        count_time_ya = millis();
        if (count_time_ya - count_time_ya_cash >= 3000)
        {
            count_time_ya_cash = millis();

            httpClientRequest(3);
        }
    }
    else if (mode == BLINKER_CMD_MIOT_WARMTH)
    { // 里间灯关闭
        count_time_bed = millis();
        if (count_time_bed - count_time_bed_cash >= 3000)
        {
            count_time_bed_cash = millis();

            httpClientRequest(2);
        }
    }
    else if (mode == BLINKER_CMD_MIOT_TV)
    {
        // Your mode function
    }
    else if (mode == BLINKER_CMD_MIOT_READING)
    {
        // Your mode function
    }
    else if (mode == BLINKER_CMD_MIOT_COMPUTER)
    {
        // Your mode function
    }

    BlinkerMIOT.mode(mode);
    BlinkerMIOT.print();
}

int counter = 0;

// 按下按键即会执行该函数
void button0_callback(const String &state)
{
    BLINKER_LOG("get button state: ", state);
    count_time_ya = millis();
    if (count_time_ya - count_time_ya_cash >= 3000)
    {
        count_time_ya_cash = millis();

        httpClientRequest(1);
    }
}

// 按下按键即会执行该函数
void button1_callback(const String &state)
{
    BLINKER_LOG("get button state: ", state);
    count_time_living = millis();
    if (count_time_living - count_time_living_cash >= 3000)
    {
        count_time_living_cash = millis();

        httpClientRequest(2);
    }
}

// 按下按键即会执行该函数
void button2_callback(const String &state)
{
    BLINKER_LOG("get button state: ", state);
    count_time_bed = millis();
    if (count_time_bed - count_time_bed_cash >= 3000)
    {
        count_time_bed_cash = millis();

        httpClientRequest(3);
    }
}

void miotPowerState(const String &state)
{
    BLINKER_LOG("need set power state: ", state);
    Serial.println("小爱同学唤醒");

    if (state == BLINKER_CMD_ON)
    {
        count_time_living = millis();
        if (count_time_living - count_time_living_cash >= 3000)
        {
            count_time_living_cash = millis();

            httpClientRequest(1);
        }
        BlinkerMIOT.powerState("off");
        BlinkerMIOT.print();
    }
    else if (state == BLINKER_CMD_OFF)
    {
        count_time_living = millis();
        if (count_time_living - count_time_living_cash >= 3000)
        {
            count_time_living_cash = millis();

            httpClientRequest(1);
        }
        BlinkerMIOT.powerState("on");
        BlinkerMIOT.print();
    }
}
// 如果未绑定的组件被触发，则会执行其中内容
void dataRead(const String &data)
{
    BLINKER_LOG("Blinker readString: ", data);
    counter++;
    Serial.println(counter);
}

void blinker_setup()
{
    // 初始化串口
    BLINKER_DEBUG.stream(Serial);
    BLINKER_DEBUG.debugAll();

    // 初始化有LED的IO
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);
    // 初始化blinker
    Blinker.begin(auth, ssid, pswd);
    Blinker.attachData(dataRead);

    BlinkerButton Button0("but0");
    Button0.attach(button0_callback);
    BlinkerButton Button1("but1");
    Button1.attach(button1_callback);
    BlinkerButton Button2("but2");
    Button2.attach(button2_callback);
    BlinkerMIOT.attachPowerState(miotPowerState);
    BlinkerMIOT.attachMode(miotMode);
}
